<?php
session_start();
$order_user = $_SESSION['userid'];
date_default_timezone_set('prc');

$tableMoney = "addmoney";

$admin_year = $_REQUEST['year'];
$admin_month = $_REQUEST['month'];
$admin_days = $_REQUEST['days'];
$admin_id = $_REQUEST['addId'];

if($admin_days==0&&$admin_id=="all"){
    $search_key = $admin_year.'-'.$admin_month;
    $reStr = $admin_year.'年'.$admin_month.'月';

    $query = mysql_query("select count(nid) from $tableMoney where left(add_money_date,7)='$search_key'");
    $sumadd = mysql_result($query, 0);
    $result = mysql_query("select * from $tableMoney where left(add_money_date,7)='$search_key' order by add_money_date desc");
    while ($row = mysql_fetch_array($result)) {
        $add_user[] = $row['add_money_user'];
        $add_name[] = $row['add_money_name'];
        $add_money[] = $row['add_money'];
        $add_admin[] = $row['add_money_admin'];
        $add_date[] = $row['add_money_date'];
        $add_department[] = $row['add_money_department'];
    }
}else if($admin_days!==0&&$admin_id=="all"){
    $search_key = $admin_year.'-'.$admin_month.'-'.$admin_days;
    $reStr = $admin_year."年".$admin_month."月".$admin_days."日";

    $query = mysql_query("select count(nid) from $tableMoney where left(add_money_date,10)='$search_key'");
    $sumadd = mysql_result($query, 0);
    $result = mysql_query("select * from $tableMoney where left(add_money_date,10)='$search_key' order by add_money_date desc");
    while ($row = mysql_fetch_array($result)) {
        $add_user[] = $row['add_money_user'];
        $add_name[] = $row['add_money_name'];
        $add_money[] = $row['add_money'];
        $add_admin[] = $row['add_money_admin'];
        $add_date[] = $row['add_money_date'];
        $add_department[] = $row['add_money_department'];
    }
}else if($admin_days==0&&$admin_id!=="all"){
    $search_key = $admin_year.'-'.$admin_month;
    $reStr = $admin_year."年".$admin_month."月 会员号：".$admin_id;

    $query = mysql_query("select count(nid) from $tableMoney where (left(add_money_date,7)='$search_key' and add_money_user='$admin_id')");
    $sumadd = mysql_result($query, 0);
    $result = mysql_query("select * from $tableMoney where (left(add_money_date,7)='$search_key' and add_money_user='$admin_id') order by add_money_date desc");
    while ($row = mysql_fetch_array($result)) {
        $add_user[] = $row['add_money_user'];
        $add_name[] = $row['add_money_name'];
        $add_money[] = $row['add_money'];
        $add_admin[] = $row['add_money_admin'];
        $add_date[] = $row['add_money_date'];
        $add_department[] = $row['add_money_department'];
    }
}else if($admin_days!==0&&$admin_id!=="all"){
    $search_key = $admin_year.'-'.$admin_month.'-'.$admin_days;
    $reStr = $admin_year."年".$admin_month."月".$admin_days."日 会员号：".$admin_id;

    $query = mysql_query("select count(nid) from $tableMoney where (left(add_money_date,10)='$search_key' and add_money_user='$admin_id')");
    $sumadd = mysql_result($query, 0);
    $result = mysql_query("select * from $tableMoney where (left(add_money_date,10)='$search_key' and add_money_user='$admin_id') order by add_money_date desc");
    while ($row = mysql_fetch_array($result)) {
        $add_user[] = $row['add_money_user'];
        $add_name[] = $row['add_money_name'];
        $add_money[] = $row['add_money'];
        $add_admin[] = $row['add_money_admin'];
        $add_date[] = $row['add_money_date'];
        $add_department[] = $row['add_money_department'];
    }
}




?>